-- TeamMemberInfoVo
-- 队伍成员信息数据结构

local Util = require("app.utils.Util")
local ActionModel = import(".ActionModel")

local fileName = string.getModeName(...)
local ClassRef = class(fileName)

-- //队伍成员信息
-- message TeamMember {
--    base.UserBaseInfo  userBaseInfo    = 1;//成员baseInfo
--    bool isLeader                      = 2;//是否是队长
--    bool isFollowLeader                = 3;//是否跟随队长
--    bool isReady                       = 4;//是否准备
--    int32 actionState                  = 5;//0-正常 1-暂离 2-战斗 3-移动 4-巡逻 剩下的是funcId
--    int64 JoinTeamStamp 								= 6;//加入队伍的时间戳
-- }
function ClassRef:ctor(data)
	self.userBaseInfo = Util.createUserBaseInfoStruct()
	self._isLeader = false
	self.isFollowLeader = false
	self._isReady = false
	self.actionState = 0
	self.joinTeamStamp = 0

	if data then
		self:read(data)
	end
end

function ClassRef:read(data)
	self.userBaseInfo = Util.createUserBaseInfoStruct( data["userBaseInfo"] )
	self._isLeader = data.isLeader or false
	self.isFollowLeader = data.isFollowLeader or false
	self._isReady = data.isReady or false
	self.actionState = data.actionState or 0
	self.joinTeamStamp = data.JoinTeamStamp or 0
end

function ClassRef:isWithTeam()
	return self.isFollowLeader
end

-- 是否是"我"？
function ClassRef:isMe()
	return self.userBaseInfo.uid == UD.player.uid
end

function ClassRef:hasPartner()
	return #self.userBaseInfo.partners ~= 0
end

-- 是否是队长
function ClassRef:isLeader()
	return self._isLeader
end

-- 返回准备状态
function ClassRef:isReady()
	return self._isReady
end

-- 清空ready状态
function ClassRef:clearReady()
	self._isReady = false
end

-- 返回成员行为状态
function ClassRef:getActionState()
	return self.actionState
end
-- 成员是否暂离
function ClassRef:isOffLeave()
	return 1 == self.actionState
end
-- 返回成员行为状态文本
function ClassRef:getActionStateStr()
	local action = tostring(self.actionState)
	return L(ActionModel[action])
end

function ClassRef:getUserBaseInfo()
	return self.userBaseInfo
end

-- 返回uid
function ClassRef:getUid()
	return self.userBaseInfo.uid
end

-- 返回name
function ClassRef:getName()
	return self.userBaseInfo.name
end

-- 返回等级
function ClassRef:getLv()
	return self.userBaseInfo.lv
end

-- 返回职业Id
function ClassRef:getClassId()
	return self.userBaseInfo.classID
end

-- 返回专精Id
function ClassRef:getSpecId()
	return self.userBaseInfo.specialistID
end

-- 返回战斗力
function ClassRef:getCapacity()
	return self.userBaseInfo.combatPower
end

-- 返回公会Id
function ClassRef:getGuildId()
	return self.userBaseInfo.guildID
end

-- 返回职责，通过技能专精判断而来
function ClassRef:getDutyType()
	local specSkillChooseConf = GD:getSpecSkillChoose( self.userBaseInfo.specialistID )
	return tonumber( specSkillChooseConf.dutyClass )
end

-- 天赋名字+职业名字，如 火焰法师（奇葩的取配置方式）
function ClassRef:getDuty()
    local ary = string.split( self.userBaseInfo.specialistID, "0" )
    local str = L("class_" .. ary[1] .. "_" .. ary[2] ) .. L("class_"..self.userBaseInfo.classID)
    return str
end
return ClassRef
